<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>专属客服</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style media="screen">
        .wrap {
            width: 100%;
            height:620px;
            position: relative;
        }

        .head {
            width: 100%;
            height: 262px;
            background: url(../../image/service_bg.png) no-repeat;
            background-size: 100% 100%;
            position: relative;
        }

        header {
            width: 100%;
            height: 44px;
            margin-top: 25px;
            float: left;
        }

        .title {
            width: 100%;
            text-align: center;
            white-space: nowrap;
            line-height: 44px;
            overflow: hidden;
            text-overflow: ellipsis;
            z-index: 2;
            color: #fff;
            font-size: 17px;
        }

        header span {
            display: block;
            width: 44px;
            height: 44px;
            background: url(../../image/white_back.png) no-repeat;
            background-size: 22px 22px;
            background-position: center;
            position: absolute;
        }

        .wrap .content {
            width: 100%;
            padding: 0 22px;
            box-sizing: border-box;
            position: absolute;
            /* bottom: 10px; */
            top: 85px;
        }

        .wrap .content .content_inner {
            width: 100%;
            height: 522px;
            position: relative;
        }

        .head_img {
            width: 100px;
            height: 100px;
            background: #C7F3FC;
            border: 1px solid #FFFFFF;
            border-radius: 50%;
            margin: 0 auto;
        }
        .head_img img{
          width: 100%;
          display: block;
          height: 100%;
          border-radius: 50%;
        }

        .wrap .content .content_inner .info {
            width: 100%;
            height: 462px;
            background: #FFFFFF;
            box-shadow: 0px 3.5px 8px 0px rgba(88, 91, 120, 0.38);
            opacity: 0.77;
            border-radius: 5px;
            /*margin-top: 60px;*/
            position: absolute;
            bottom: 10px;
        }

        .wrap .content .content_inner .info .text {
            width: 100%;
            text-align: center;
            height: 17px;
            line-height: 17px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: bold;
            color: #095AC1;
            margin-top: 59px;
        }

        .wrap .content .content_inner .info .wechat {
            width: 100%;
            text-align: center;
            height: 15px;
            line-height: 15px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: bold;
            color: #095AC1;
            margin-top: 15px;
        }

        .wrap .content .content_inner .info .copy {
            width: 177px;
            text-align: center;
            height: 37px;
            line-height: 37px;
            font-size: 16px;
            font-family: PingFang SC;
            /*font-weight: bold;*/
            color: #fff;
            background: #095FC4;
            border-radius: 18.5px;
            margin: 0 auto;
            margin-top: 15px;
        }

        .longpress {
            width: 100%;
            text-align: center;
            height: 17px;
            line-height: 17px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: bold;
            color: #095AC1;
            margin-top: 51px;
        }

        .picture {
            width: 188px;
            height: 188px;
            margin: 0 auto;
            margin-top: 18px;
            background: url(../../image/erweima_bg.png) no-repeat;
            background-size: 100% 100%;
        }
        .picture img{
          width: 100%;
          display: block;
          height: 100%;
        }

        .note {
            width: 100%;
            height: 15px;
            line-height: 15px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #095AC1;
            padding-left: 22px;
            box-sizing: border-box;
            margin-top: 25px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="wrap">
            <div class="head">
                <header id="header">
                    <span tapmode @click="closeWin()"></span>
                    <div class="title">专属客服</div>
                </header>
            </div>
            <div class="content">
                <div class="content_inner">
                    <div class="head_img"><img :src="appinfo.logo" alt=""></div>
                    <div class="info">
                        <div class="text">专属客服</div>
                        <div class="wechat">微信号：{{serviceInfo.cvalue}}</div>
                        <div class="copy" tapmode onclick='vm.copyinvitecode()'>复制微信号</div>
                        <div class="longpress">长按保存微信二维码</div>
                        <div class="picture"><img :src="serviceInfo.pic" alt=""></div>
                    </div>
                </div>
            </div>


        </div>
        <div class="note">添加微信有助于帮您解决任何问题哦~</div>

    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript" src="../../script/aui-actionsheet.js"></script>
<script type="text/javascript">
    apiready = function() {
        api.addEventListener({
            name: 'longpress'
        }, function(ret, err) {

            var actionsheet = new auiActionsheet();
            actionsheet.init({
                frameBounces: true, //当前页面是否弹动，（主要针对安卓端）
                cancelTitle: '取消',
                buttons: ['保存到图库']
            }, function(ret) {
                if (ret) {
                    console.log(ret.buttonIndex);
                    if (ret.buttonIndex == 1) {
                        api.download({
                            url: vm.serviceInfo.pic,
                            report: true,
                            cache: true,
                            allowResume: true,
                            savePath: 'fs://test.jpg',
                        }, function(ret, err) {
                            // alert(JSON.stringify(ret))
                            api.saveMediaToAlbum({
                                path: 'fs://test.jpg'
                            }, function(ret, err) {
                                if (ret && ret.status) {
                                    cl.toast({
                                        msg: '保存成功'
                                    })
                                } else {
                                    alert('保存失败');
                                }
                            });
                            // alert('(保存)ret:'+ JSON.stringify( ret ) +',ret.state:'+ret.state+',err:'+ JSON.stringify( err ) );   //返回ret.state为2。。。
                        });

                    }
                    // document.getElementById("button-index").textContent = ret.buttonIndex;
                    // document.getElementById("button-title").textContent = ret.buttonTitle;
                }
            })

        });

        vm.init();
        vm.appinfo = $api.getStorage('appinfo');
        console.log(JSON.stringify(vm.appinfo));
    }
    var vm = new Vue({
        el: '#app',
        data: {
         serviceInfo:'',
         appinfo:''
        },
        methods: {
          init:function(){
            api.ajax({
                url: cl.apiServer + 'cpssystemConfig/getCategoryList',
                method: 'post',
                headers: {
                    'Content-Type': 'application/json;charset=utf-8',
                    token:cl.userToken
                },
                data: {
                    body: {
                        type:12,
                        version:cl.deviceInfo().appVersion,
                        mobileInfo:cl.systemType()
                    }
                }
            }, function(ret, err) {
                // alert(JSON.stringify(ret));
                if (ret) {
                    if (ret.code == 0) {
                      vm.serviceInfo = ret.data[0];
                        // vm.dataList = ret.data;
                    }
                }
            });
          },
            closeWin: function() {
                cl.closeWin({
                    name: 'service'
                })
            },
            copyinvitecode: function() {
                var clipBoard = api.require('clipBoard');
                clipBoard.set({
                    value: vm.serviceInfo.cvalue
                }, function(ret, err) {
                    if (ret) {
                        // alert(JSON.stringify(ret));
                        if (ret.status) {
                            clipBoard.get(function(ret, err) {
                                if (ret) {
                                    cl.toast({
                                      msg:'复制成功'
                                    })
                                } else {
                                    // alert(JSON.stringify(err));
                                }
                            });
                        }
                    } else {
                        alert(JSON.stringify(err));
                    }
                });
            },
        }
    });
</script>

</html>
